/**
 * 
 */
package cn.txdnet.txcms.upload;
import org.apache.commons.fileupload.FileItem;
import txdnet.util.FileUtil;
import txdnet.util.Logger;
import txdnet.util.uploader.apache.fileupload.UploadFileFilter;

/**
 * @author txdnet
 *
 */
public class UploadFilter implements UploadFileFilter {

	/* (non-Javadoc)
	 * @see txdnet.util.uploader.apache.fileupload.UploadFileFilter#check(org.apache.commons.fileupload.FileItem)
	 */
        private String allowext;
        public UploadFilter(String allowext){
            this.allowext = allowext;
        }
        
	@Override
	 public boolean check(FileItem item){
        boolean flag ;
        try{ 
            flag = (allowext.contains(FileUtil.getFileExt(item.getName()).toLowerCase()));
        }catch(Exception e){
            Logger.error(UploadFilter.class, e.toString());
            flag = false;
        }
      return flag;
   }
}
